package com.gc.notify.message;

import com.gc.notify.GovcarObserver;
import com.gc.common.entity.Message;
import com.gc.frontend.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Created by 瑱彬 on 2015/4/30.
 */
@Component(value = "notifyObserver")
@Scope("singleton")
public class NotifyObserver implements GovcarObserver {

    @Autowired
    private MessageService messageService;

    @Override
    public void update(Map<String, Object> messageEntity) {
        Message message = (Message) messageEntity.get("message");
        messageService.insert(message);
    }
}
